package com.study.lambda.basedemo;

import java.util.function.UnaryOperator;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2021/5/29 20:50
 */
public class LambdaDemo03
{
    public static void main(String[] args)
    {
        User2 user2 = new User2();
        user2.setUsername("javaboy");
        // String say = user2.say((username) -> "hello " + username);
        // System.out.println("say = " + say);

        UnaryOperator<String> func = (username) -> "helloo " + username;
        String say = user2.say(func);
        System.out.println("say = " + say);
    }
}

class User2
{
    private String username;

    public String getUsername()
    {
        return username;
    }

    public void setUsername(String username)
    {
        this.username = username;
    }

    // public String say(Function<String, String> sayHello)
    // {
    //     return sayHello.apply(this.username);
    // }

    public String say(UnaryOperator<String> sayHello) {
        return sayHello.apply(this.username);
    }
}
